#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
using ll=long long;
const int MOD=100003;

int qmi(ll a,ll b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=(ll)ret*a%MOD;
		a=(ll)a*a%MOD;
		b>>=1;
	}
	return ret;
}
int main()
{
	ll n,m;
	cin>>m>>n;
	cout<<(qmi(m,n)-(ll)m*qmi(m-1,n-1)%MOD+MOD)%MOD<<endl;
	return 0;
}
